<?php


//  http://www.phpandstuff.com/articles/codeigniter-doctrine-scratch-day-3-user-signup-form

// access via http://www.dixieandtheninjas.net/dynasties3/zsignup_con
// this file is 'signup.php' in the tutorial

class Add_user_static extends CI_Controller {

	public function __construct() {
		parent::__construct(); 
                // the tutorial shows this as 
                // parent::Controller();
                
                $this->load->helper(array('form','url'));
                $this->load->library('form_validation');
	}

	public function index() {
		$this->load->view('testing/placeholder_view');
                
                $user = new ORM\Testing\User;
                $user->setFirstName('Bobby');
                $user->setLastName('Brown');
                $user->setPassword(md5('Emma Watson'));
                $user->setEmail('bobby@bobbybrown.com');
                $user->setWebsite('http://www.bobbybrown.com');
                $user->setCreated(new DateTime());

                // standard way in CodeIgniter to access a library in a controller: $this->library_name->member->memberFunction()
                // save the object to database, so that it can obtain its ID
                $this->doctrine->em->persist($user);

                // create a new article object
                $article = new ORM\Testing\Article;
                $article->setTitle('Isn\'t my article great?');
                $article->setContent('I am sure there is some content here.');
                $article->setCreated(new DateTime());
                // the user object you pass must be persisted first!
                $article->setUser($user);

                // save the article object to the database
                $this->doctrine->em->persist($article);
                $this->doctrine->em->flush();

                echo $article->getID();
                echo "<b></br>Success!</b>";
                
                
	}
        
        

}



?>
